﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PlatForm.DataLayer;

namespace PlatForm.Controller
{
    public class SupplierController
    {
        public List<Supplier> GetList()
        {
          return Supplier.Objects.ToList();
        }

        public int Save(Supplier supplier)
        {
            var isNew = 1;
            var s = Supplier.Objects.FirstOrDefault(x => x.SUPPL_No == supplier.SUPPL_No);
            if (s != null)
            {
                Supplier.Objects.Delete(x => x.SUPPL_No == supplier.SUPPL_No);
                isNew = 0;
            }
            supplier.Insert(true);
            return isNew;
        }

        public void Delete(string SUPPL_No)
        {
            Supplier.Objects.Delete(x => x.SUPPL_No == SUPPL_No);
        }
    }
}
